package com.android.phoenix.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.phoenix.R;

public class MyOfflineMapCityListAdapter extends BaseAdapter {
	private String[] citys = null;
	private Context context;
	private LayoutInflater inflater = null;
	private ViewHolder vholder;

	public MyOfflineMapCityListAdapter(Context context, String[] citys) {
		this.citys = citys;
		this.context = context;
		this.inflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return citys.length;
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return citys[arg0];
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		if (arg1 == null) {
			vholder = new ViewHolder();
			arg1 = inflater.inflate(R.layout.list_offlinemap_cityitem, null);

			vholder.tvCity = (TextView) arg1
					.findViewById(R.id.tvOfflineMapCityItem);
			vholder.tvSize = (TextView) arg1
					.findViewById(R.id.tvOfflineMapSizeItem);
			vholder.tvInstall = (TextView) arg1
					.findViewById(R.id.tvOfflineMapInstallItem);
			vholder.imgDownload = (ImageView) arg1
					.findViewById(R.id.imgOfflineMapDownloadItem);
			arg1.setTag(vholder);
		} else {
			vholder = (ViewHolder) arg1.getTag();
		}
		vholder.tvCity.setText(citys[arg0]);
		vholder.tvSize.setText("34.2MB");
		return arg1;
	}

	public final class ViewHolder {
		public TextView tvCity;
		public TextView tvSize;
		public TextView tvInstall;
		public ImageView imgDownload;
	}

}
